package Test.Exam;

import java.util.Scanner;

/**
 * @ClassName problem_5
 * @since: 2024/3/9 19:21
 * @auth: kirito
 * @description:
 **/
public class problem_6 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        while (sc.hasNext()) {
//        int s = sc.nextInt();
            String a = sc.nextLine();
            System.out.println(f(
//                    s,
                    a));
//        }

    }

    private static int f(
//            int len,
            String input) {
        if (input == null || input.isEmpty()) {
            return 0;
        }
        int maxLength = 0;
        int len = input.length();
        for (int i = 0; i < len; i++) {
            if (input.charAt(i) == 'a') {
                int j = i + 1;
                while (j < len && input.charAt(j) != 'h') {
                    j++;
                }
                if (j - i == maxLength / 2) {
                    maxLength = 2 * j - i;
                }
            }

        }
        return maxLength;
    }
}
